package cn.hyy.hrm.client;


import cn.hyy.basic.util.AjaxResult;
import cn.hyy.hrm.client.impl.FileClientImpl;
import cn.hyy.hrm.client.config.FeignSupportConfig;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;


@FeignClient(value = "DFS-SERVICE",configuration = FeignSupportConfig.class,fallback = FileClientImpl.class)
public interface FileClient {

    /**
     * 文件上传
     * @param file
     * @return
     */
    @PostMapping(value = "/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    AjaxResult upload(@RequestPart(value = "file")MultipartFile file);

    /**
     * 文件下载
     * @param fileId 文件标识
     * @return
     */
    @GetMapping(value = "/download")
    Response download(@RequestParam("fileId")String fileId);

    /**
     * 文件删除
     */
    @GetMapping("/delete")
    AjaxResult delete(@RequestParam("fileId") String fileId);
}
